#!/bin/bash

echo "=== Testing SHOW TABLES Fix ==="

# Start server in background and capture output
./bin/gudb-server -h localhost -P 7777 -u admin -p admin123 -d /tmp/gudb_data &
SERVER_PID=$!

# Wait for server to start
sleep 3

echo "Testing SHOW TABLES without USE:"
./bin/gu -h localhost -P 7777 -u admin -p admin123 -i << 'EOF'
SHOW TABLES;
quit
EOF

echo -e "\nTesting SHOW TABLES with USE:"
./bin/gu -h localhost -P 7777 -u admin -p admin123 -i << 'EOF'
USE altertest;
SHOW TABLES;
quit
EOF

# Stop server
kill $SERVER_PID 2>/dev/null
wait $SERVER_PID 2>/dev/null

echo "=== Test Complete ==="